package com.hdsx.jxcsxm.tjbb.server.impl;

import com.hdsx.dao.query.base.BaseOperate;
import com.hdsx.jxcsxm.tjbb.bean.*;
import com.hdsx.jxcsxm.tjbb.server.SbzjGtzjServer;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class SbzjGtzjServerImpl  extends BaseOperate implements SbzjGtzjServer {

    public SbzjGtzjServerImpl() {
        super("tjbb", "jdbc");
    }

    @Override
    public List<Gtzjjhlr> autoGtzjxmmc(String trim) {
        return queryList("autoGtzjxmmc",trim);
    }

    @Override
    public boolean insertSbzjGtzjjhlr(Gtzjjhlr gtzjjhlr, List<Map> data) {
        Cgsjhlr x=queryOne("getsbzjGtzjById", gtzjjhlr);
//			for (Map map : data) {
//				System.out.println(map);
//			}
        if(x!=null) {
            //修改主表
            //update("updateSbzjCgsjhlr", cgsjhlr);
            //添加子表
            //if(!"".equals(cgsjhlr.getBcje()))
            // insert("insertSbzjsqmx", xmjbxx);
            // update("updateZhjhje",xmjbxx);
            System.out.println("修改成功");
        }
        else {
            boolean insertBatch = insertBatch("insertSbzjGtzjjhlrmx", data)==data.size();
            if (insertBatch) {
                insert("insertSbzjGtzjjhlr", gtzjjhlr);
                return true;
            }
            //insert("insertSbzjCgsjhlrmx", data);
            //insertBatch("insertSbzjCgsjhlrmx", data)==data.size();
            //System.out.println("添加项目成功");
        }
        return true;
    }

    @Override
    public boolean checkgtzjNameCf(Gtzjjhlr gtzjjhlr) {
        int i=queryOne("checkgtzjNameCf",gtzjjhlr);
        if (i > 0) {
            return true;
        }else {
            return false;
        }
    }

    @Override
    public List<Gtzjjhlr> getsbzjGtzjById(Gtzjjhlr gtzjjhlr) {
        return queryList("getsbzjGtzjById",gtzjjhlr);
    }

    @Override
    public List<Gtzjjhlr> selectsbzjGtzjList(Gtzjjhlr gtzjjhlr) {
        return queryList("selectsbzjGtzjList",gtzjjhlr);
    }

    @Override
    public int selectsbzjGtzjListCount(Gtzjjhlr gtzjjhlr) {
        return queryOne("selectsbzjGtzjListCount",gtzjjhlr);
    }

    @Override
    public List<GtzjjhlrMx> queryGtzjlist(GtzjjhlrMx gtzjjhlrMx) {
        return queryList("queryGtzjlist",gtzjjhlrMx);
    }

    @Override
    public int queryGtzjlistCount(GtzjjhlrMx gtzjjhlrMx) {
        return queryOne("queryGtzjlistCount", gtzjjhlrMx);
    }

    @Override
    public boolean delGtzjjhlr(Gtzjjhlr gtzjjhlr) {
        delete("delGtzjjhlr",gtzjjhlr);
        delete("delGtzjjhlrMxbyjhid",gtzjjhlr);

        delete("delFileByParentid", gtzjjhlr);
        delete("delFileRelationByXmbm", gtzjjhlr);

        return true;
    }

    @Override
    public boolean delGtzjjhlrMx(GtzjjhlrMx gtzjjhlrMx) {
        return delete("delGtzjjhlrMx",gtzjjhlrMx)>0;
    }

    @Override
    public Bkzh autogtzjhmNcgl(String xmdj) {
        return queryOne("autogtzjhmNcgl",xmdj);
    }

    @Override
    public Bkzh autogtzjhmGsd(String xmdj) {
        return queryOne("autogtzjhmGsd",xmdj);
    }

    @Override
    public GtzjjhlrMx sumyeBygtzjBJID(GtzjjhlrMx gtzjjhlrMx) {
        return queryOne("sumyeBygtzjBJID", gtzjjhlrMx);
    }

    @Override
    public boolean updateSbzjgtzjjhlrMx(GtzjjhlrMx gtzjjhlrMx) {
        int update = update("updateSbzjgtzjjhlrMx", gtzjjhlrMx);
        return true;
    }

    @Override
    public boolean updateSbzjgtzjjhlr(Gtzjjhlr gtzjjhlr) {
        int update = update("updateSbzjgtzjjhlr", gtzjjhlr);
        return true;
    }

    @Override
    public Bkzh autocgshmNcgl(String xmdj) {
        return queryOne("autocgshmNcgl",xmdj);
    }

    @Override
    public Bkzh autocgshmGsd(String xmdj) {
        return queryOne("autocgshmGsd",xmdj);
    }

    @Override
    public Gtzjjhlr selectsumyegtzj(Gtzjjhlr gtzjjhlr) {
        return queryOne("selectsumyegtzj",gtzjjhlr);
    }
}
